﻿package org.cshoo.sys.business.service;

import java.util.List;

import org.cshoo.sys.business.iservice.IOrganizationService;
import org.cshoo.sys.data.entity.Organization;
import org.cshoo.sys.data.idao.IOrganizationDAO;

/**
 * 组织机构管理
 * @author 杨翼
 * 2013年4月10日
 */
public class OrganizationService implements IOrganizationService{
	
	private IOrganizationDAO organizationDAO;

	public void setOrganizationDAO(IOrganizationDAO organizationDAO) {
		this.organizationDAO = organizationDAO;
	}
	
	/**
	 * 添加一个组织机构
	 * @param organization
	 * @return
	 */
	public Organization addOrganization(Organization organization){
		return (Organization)organizationDAO.addObject(organization);
	}
	
	/**
	 * 修改一个组织机构信息
	 * @param organization
	 * @return
	 */
	public Boolean updateOrganization(Organization organization){
		Boolean result = false;
		organizationDAO.updateObject(organization);
		result = true;
		return result;
	}
	
	/**
	 * 删除一个组织机构
	 * @param organization
	 * @return
	 */
	public Boolean deleteOrganization(Organization organization){
		Boolean result = false;
		organizationDAO.deleteObject(organization);
		result = true;
		return result;
	}
	
	/**
	 * 查询根组织机构的集合，由于组织机构为树形递归，
	 * 所以只需要查出根的集合就相当于查出所有的组织机构
	 * @return
	 */
	public List findRootOrganizationList(){
		return organizationDAO.findRootOrganizationList();
	}
}
